package com.web.common.basic.api;

import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.ResponseBody;
import com.web.common.api.config.ServiceInstanceName;
import com.web.common.basic.elasticsearch.entity.ElasticIndexParam;
import com.web.common.basic.elasticsearch.entity.ElasticIndices;
import com.web.common.basic.elasticsearch.entity.ElasticParam;
import com.web.common.basic.entity.SimplePage;
import com.web.common.basic.elasticsearch.entity.ElasticDataListParam;
import com.web.common.result.R;
import com.web.common.security.FeignInnerEntity;

@FeignClient(name = ServiceInstanceName.SERVICE_BASIC_NAME, contextId = "elasticsearchApi", path = "/basic/elasticsearch")
public interface ElasticsearchApi {
	
	/**
	 * 自定义操作
	 * @param param 操作的参数信息
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.10.24 
	 */
	@PostMapping(path = "/customOperate")
	@ResponseBody
	R<Object> customOperate(@Valid @RequestBody ElasticParam param, 
			@RequestHeader(name = FeignInnerEntity.HTTP_HEADER_INNER, required = false, defaultValue = FeignInnerEntity.HTTP_INNER_VALUE) String value);

	/**
	 * 获取索引列表
	 * @return R<List<String>> 索引列表
	 *
	 * @author zhouhui
	 * @since 2023.07.01
	 */
	@PostMapping(path = "/index/list")
	@ResponseBody
	R<List<ElasticIndices>> getIndexList();
	
	/**
	 * 获取索引的详细信息
	 * @param param 索引名称
	 * @return 
	 *
	 * @author zhouhui
	 * @since 2023.11.01 
	 */
	@PostMapping(path = "/index")
	@ResponseBody
	R<Map<String, Object>> getIndex(@RequestBody ElasticIndexParam param);
	
	/**
	 * 创建索引
	 * @param index 索引值
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.07.01
	 */
	@PostMapping(path = "/createIndex")
	@ResponseBody
	R<Object> createIndex(@Valid @RequestBody ElasticIndexParam param);
	
	/**
	 * 更新索引的mapping
	 * @param index 索引值
	 * @return R<Object> 处理结果
	 *
	 * @author zhouhui
	 * @since 2023.07.01
	 */
	@PostMapping(path = "/updateIndexMapping")
	@ResponseBody
	R<Object> updateIndexMapping(@Valid @RequestBody ElasticIndexParam param);
	
	/**
	 * 获取索引对应的数据量
	 * @param param 查询条件
	 * @return Integer 数据量
	 *
	 * @author zhouhui
	 * @since 2023.11.03 
	 */
	@PostMapping(path = "/getIndexCount")
	@ResponseBody
	R<Integer> getIndexCount(@RequestBody ElasticIndexParam param);
	
	/**
	 * 删除索引信息
	 * @param param 索引信息
	 * @return R<Object>处理结果
	 *
	 * @author zhouhui
	 * @since 2023.11.03 
	 */
	@PostMapping(path = "/deleteIndex")
	@ResponseBody
	R<Object> deleteIndex(@RequestBody ElasticIndexParam param);
	
	/**
	 * 获取存储的数据列表
	 * @param param 查询信息
	 * @return R<IPage<Object>> 数据结果
	 *
	 * @author zhouhui
	 * @since 2024.04.26 
	 */
	@PostMapping(path = "/getDataList")
	@ResponseBody
	R<SimplePage> getDataList(@RequestBody ElasticDataListParam param);
}
